<%--
  Created by IntelliJ IDEA.
  User: zhaoh
  Date: 2021/5/14
  Time: 22:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/public/header/permissionCommon.jspf" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>签到签退信息展示</title>
    <c:set var="path" value="${pageContext.request.contextPath}" scope="page"/>
    <style type="text/css">
        .layui-table-tips-main{display:none}
        .layui-table-tips-c{display:none}
        .layui-table-grid-down {display: none;}
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部和左侧导航-->
    <div id="header"></div>
    <%--<!--右侧主体区域-->--%>
    <div class="layui-body" >
        <div class="layui-tab layui-tab-brief" lay-filter="SignList">
            <ul class="layui-tab-title">
                <li class="layui-this">签到签退异常信息展示</li>
            </ul>
            <div class="layui-tab-content">
                <%-----------签到签退展示-----------%>
                <div id="SignInfoShow" class="layui-tab-item layui-show">
                    <%-----------搜索 & 文件导出 功能-----------%>
                    <div class="SearchLoadSign" style="font-size: small">
                        <%------------搜索功能---------------%>
                        老人医保卡：
                        <div class="layui-inline">
                            <input class="layui-input" name="lr_id" id="lr_id" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        老人姓名：
                        <div class="layui-inline">
                            <input class="layui-input" name="lr_name" id="lr_name" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        护工姓名：
                        <div class="layui-inline">
                            <input class="layui-input" name="hg_name" id="hg_name" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        状态：&nbsp&nbsp异常&nbsp&nbsp
                        <div class="layui-input-inline layui-form" style="width: 150px;display: none">
                            <select name="statusSearch" id="statusSearch" lay-filter="statusSearch" class="select" disabled>
                                <option value="-1">异常</option>
                            </select>
                        </div>

                        <div class="layui-inline">
                            <button class="searchBtn" data-type="reload1" style="margin-left:10px;height:30px;width:85px;background-color: #009688;color: white;border: none;border-radius: 5px">
                                <i class="layui-icon layui-icon-search"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -6px;margin-left: 5px;margin-right: 5px">搜 索</div>
                            </button>
                        </div>
                        <%-------------文件导出-------------%>
                        <div class="layui-inline" style="float: right">
                            <button class="layui-btn layui-btn-sm" id="exportExcel" name="exportExcel" style="width: 100px;float: right;border-radius: 5px;margin-left: 5px">
                                <i class="layui-icon layui-icon-export"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center">导出文件</div>
                            </button>
                        </div>
                    </div>
                    <%----------- 信息表格 显示------------%>
                    <table class="layui-hide" id="signInfoList" lay-filter="sign" ></table>
                </div>
            </div>
        </div>
    </div>
    <!--底部-->
    <div id="footer"></div>
    <script src="${webPath}/js/permission/auth/permList.js"></script>
    <script>
        $("#header").load("${webPath}/publicPages/permission/fragments/header.jsp");
        $("#footer").load("${webPath}/publicPages/permission/fragments/footer.jsp");
    </script>
    <script type="text/javascript" src="${webPath}/js/Sign/SignAlarmList.js"></script>
    <%-------------编辑删除框--------------%>
    <%--查看页面的编辑框--%>
    <script type="text/html" id="Check_Edit_Del">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script type="text/javascript" src="${webPath}/js/utils.js"></script>

    <div class="signDetail" id="SignDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >老人医保卡</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_id" value={lr_id} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">老人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_name" value={lr_name} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">护工ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_id" value={hg_id} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">护工姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_name" value={hg_name} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属机构</label>
                <div class="layui-input-block">
                    <input type="text" name="organization_name" value={organization_name} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">首次签到</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="f_sign" readonly="readonly" value={f_sign}  class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">离开签退</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="t_sign" readonly="readonly" value={t_sign} step="1" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">签到状态</label>
                    <div class="layui-input-block">
                        <input type="text" name="state" value={state} readonly="readonly" class="layui-input">
                    </div>
                </div>
            </div>
        </form>
    </div>

    <div class="editSign" id="SignEdit" style="display: none;">
        <form class="layui-form layui-form-pane" id="DepartmentForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>老人医保卡</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_id" value={lr_id} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>老人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_name" value={lr_name} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>护工ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_id" value={hg_id} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>护工姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_name" value={hg_name} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>所属机构</label>
                <div class="layui-input-block">
                    <input type="text" name="organization_name" value={organization_name} lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">首次签到</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="f_sign" class="layui-input" value={f_sign} step="1">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">签退离开</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="t_sign" class="layui-input" value={t_sign} step="1">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>状态</label>
                    <div class="layui-input-block">
                        <select name="state" id="state" disabled>
                            <option value="0" {select1}>正常</option>
                            <option value="-1" {select2}>异常</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input type="text" name="id" value={id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handin" lay-filter="handin" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handin)', function(data){
                console.log("[开始提交~]");
                console.log(data.field);
                $.ajax({
                    url:'/Sign/updateSignInfo',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

    <script type="text/javascript">
        layui.config({//配置并导入excel插件
            base: '${base}/js/layui_exts/'
        }).use([ 'excel', 'layer'], function() {
            var $ = layui.$;
            var layer = layui.layer;
            var excel = layui.excel;
            $('#exportExcel').on('click', function(){
                console.log("触发导出按钮");
                layer.confirm('是否确认导出?', function(index) {
                    $.ajax({
                        url: '/Sign/getSignList'
                        ,method:'post'
                        ,data: {
                            state:-1
                        }
                        , dataType: 'json'
                        , success(res) {
                            var data = res.list;
                            console.log(data);
                            layer.close(index);
                            data = excel.filterExportData(data, [
                                'id'
                                , 'lr_id'
                                , 'lr_name'
                                , 'hg_id'
                                , 'hg_name'
                                , 'organization_name'
                                , 'f_sign'
                                , 't_sign'
                                , 'state'
                            ]);
                            data.unshift({
                                id: "序号", lr_id: "老人医保卡",
                                lr_name: "老人姓名", hg_id: "护工ID",
                                hg_name: "护工姓名", organization_name: "所属机构",
                                f_sign: "首次签到",
                                t_sign: "签退离开", state: "状态"
                            });
                            // var timestart = Date.now();
                            excel.exportExcel(data, '签到信息导出--' + new Date().toLocaleString() + '.xlsx', 'xlsx');
                            //	var timeend = Date.now();
                            //	var spent = (timeend - timestart) / 1000;
                            //	console.log('单纯导出耗时 '+spent+' s');
                        }
                        , error() {
                            layer.alert('获取数据失败，请检查是否部署在本地服务器环境下！');
                        }
                    });
                });
            });
        });
    </script>
</div>

</body>
</html>
